<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #result{
            width: 200px;
            height: 200px;
            border: 2px solid;
        }
    </style>
</head>
<body>
    <div id="result"></div>
</body>
<script>
    const result = document.getElementById('result');
    result.addEventListener('mouseover',function(){
        const xhr = new XMLHttpRequest();
        //初始化
        xhr.open('POST','http://127.0.0.1:8000/server');
        // send可设置请求体
        xhr.send();
        xhr.onreadystatechange = function(){
            if(xhr.readyState===4){
                if(xhr.status>=200 && xhr.status<300){
                    result.innerHTML = xhr.response;
                }
            }
        }
    });
    result.addEventListener('mouseout',function(){
        result.innerHTML='';
    })
</script>
</html>